<html>
<head>
    <script type="text/javascript" src="aes-lib.js">/* AES JavaScript implementation */</script>
</head>
<body>

<script lang="js">

var t = 'goats are falling from the sky, hi helen';
var p = "hello";
var enc = 'M7u4SkJCQkI9GQ81AJYtEi/uMezvWvYJVeuJd9Q5z3VFLtDwaIerd/xOPxZJ+uVP';
var enc = 'AAECAwQFBgcy+vizFdceHkzH4lEsJHSmsYlksP4eqL/4t53V96CtdNFEmqJhJDbkjZTyYIPt/Po2yQEfq8gk1MbVqQ==';
var dec = AESDecryptCtr(enc, p, 128);
//alert(enc);
alert(dec);

var t = 'goats might fly. well they might, for they might fly indeed';
var enc = AESEncryptCtr(t, p, 128);
alert(enc);
var dec = AESDecryptCtr(enc, p, 128);
alert(dec);

// var iterator = document.evaluate('//text()', document, null,                    XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null );
// var thisNode = iterator.iterateNext();
// var d = Array();
// 
// var reg = /^\{AES\}([0-9A-Za-z=/\+]+)/;
// 
// while (thisNode) {
//     var m = reg.exec(thisNode.textContent);
//     if (m != null) {
//         var dec = m[1];
//         d.push(Array(thisNode, dec))
//     }
//     thisNode = iterator.iterateNext();
// }
// 
// for (var idx=0; idx<d.length; ++idx) {
//     var node = d[idx][0];
//     var dec = d[idx][1];
//     var unc = AESDecryptCtr(dec, p, 128);
//     node.textContent = unc;
// }

</script>
</body>
</html>